﻿using System;
using FinPlusComponents;
using QLNet;
using p = FinPlusAnalytics.QLConvParser;

namespace FinPlusAnalytics
{
    public class FutRate : FinPlusComponent
    {
        public string Name { get; private set; }
        public RelinkableHandle<Quote> Rate { get; private set; }
        public RateHelper RateHelper { get; private set; }

        public FutRate(string marketName, string name, double rate, DateTime startDate, int futMonths, string dayCount, string bizConv, string holidays, bool endOfMonth = true)
        {
            Name = name;
            var market = Markets.Instance.GetMarket(marketName);

            Rate = market.GetQuote(name);
            Rate.linkTo(new SimpleQuote(rate));
 
            RateHelper = new FuturesRateHelper(Rate, startDate, futMonths, p.Calendar(holidays), p.BizConv(bizConv), endOfMonth, p.DayCount(dayCount));
            market.SetRateHelper(name, RateHelper);
        }
    }
}
